Let’s Make a Bad Plot!
knitr::opts_chunk$set(echo = TRUE,
warning=FALSE)
bad_plot <- ggplot()+
theme(panel.grid.major=element_line(color="green"), #change the color of my gridlines to green
panel.grid.minor=element_line(color="magenta"), #and magenta
text=element_text(family = "Curlz MT",size=15, color="dodgerblue", face="bold"), #make my text this font, size, color, and bold
axis.text=element_text(family="Showcard Gothic", size=13, color="yellow"))+ #change my axis text on my plot to this font, size, and color
geom_point(data=eruption_full, aes(x=year, y=longitude, #make a scatterplot with y as longitude, color as name of voclano, and size as latitude
color=volcano_name,
size=latitude))+
scale_color_manual(values=c("dodgerblue","blue1","blue2","blue3", #manually change the colors of my data points
"slateblue","deepskyblue", "cornflowerblue",
"skyblue", "cadetblue1", "darkturquoise"))+
labs(title="Coordinates of Active Volcanos During 2015-2019") #give my plot a title
volcanoeruption="http://clipart-library.com/images/riLo9gGaT.gif" #this is the link to the background image
ggbackground(bad_plot, volcanoeruption)#+ #add a background to my image

#ggsave(here("GoodPlot_BadPlot", "Output", "BadPlot.png"))
What makes this a bad plot?
- Overall, this plot is very, very ugly:
- The background is hideous
- The gride lines do not match well and are very jarring to look
at
- The font is just awful
- This plot is difficult to interpret:
- Latitude and longitude should be plotted on a map
- Latitude and longitude should be on the y and axis axes,
respectively, and one should certainly NOT be represented by
size
- The colors representing each volcano are nearly indistinguishable
(though they are different!)
Let’s Make a Good Plot!
knitr::opts_chunk$set(echo = TRUE,
warning=FALSE)
coords_animated <- ggmap(coords)+ #create a function with the coords map
geom_point(data=eruption_full, aes(x=longitude, y=latitude, #and create a scatterplot using eruption_full data with x as longitude, y as latitude, color as the name of the volcano, size of points is 4, and partially opque
color=volcano_name), size=4.5,
alpha=0.75)+
transition_states(year, #create an animated plot that views data by year
transition_length=2, #takes 2 seconds to transition from year-to-year
state_length=5)+ #remain at one year for 5 seconds
ggtitle("Year: {closest_state}")+ #make my plot title change by year and represent "year"
labs(subtitle="Active Volcanos in Japan by Year, 2015-2019", #this is my subtitle
x="Longitude", #this is my x axis title
y="Latitude", #this is my y axis title
color="Name of Volcano")+ #this is my color legend title
scale_x_continuous(limits=c(128, 149))+ #limit my x axis
scale_y_continuous(limits=c(28,45))+ #and my y axis
theme(text=element_text(family = "Trebuchet MS",size=12))+ #change the text font and size
scale_color_manual(values=c("cyan","coral4","slateblue","black","green","yellow")) #manually change the colors of my values
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
## Scale for y is already present.
## Adding another scale for y, which will replace the existing scale.
animate(coords_animated, height=6, width=6, units="in", res=200)#+ #animate my plot
